//
//  EastMarketTabBar.m
//  EastMarket
//
//  Created by 李鹏程 on 16/10/12.
//  Copyright © 2016年 guoguo. All rights reserved.
//

#import "EastMarketTabBar.h"
#define ButtonNumber 5

@implementation EastMarketTabBar

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)layoutSubviews{
    [super layoutSubviews];
    
    CGFloat barWidth = self.frame.size.width;
    CGFloat barHeight = self.frame.size.height;
    CGFloat buttonW = barWidth / ButtonNumber;
    CGFloat buttonH = barHeight - 1;
    CGFloat buttonY = 0;
    NSInteger buttonIndex = 0;
    
    //self.publishButton.center = CGPointMake(barWidth * 0.5, barHeight * 0.3);
    for (UIView *view in self.subviews) {
        
        NSString *viewClass = NSStringFromClass([view class]);
        if (![viewClass isEqualToString:@"UITabBarButton"]) continue;
        
        CGFloat buttonX = buttonIndex * buttonW;
        view.frame = CGRectMake(buttonX, buttonY, buttonW, buttonH);
        view.backgroundColor = EastMarket_TabbarBackColor;
        view.layer.borderColor = EastMarket_TabbarTopLineBackColor.CGColor;
        view.viewBorder = viewBorderTop;
        
        buttonIndex ++;
    }
}

@end
